package com.lty.practice.rabbitmq.customer.controller;

import com.lty.practice.rabbitmq.customer.model.Order;
import com.lty.practice.rabbitmq.customer.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/newOrder")
    public void newOrder(@RequestBody Order order) {
        try {
            orderService.newOrder(order);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
